% Matlab file to implement class "deriv1",
% forward mode of automatic differentation, first derivatives
% Michael Reiter, Universitat Pompeu Fabra, April 2007
% Last update: -
% Feel free to use, copy and modify at your own risk;
%   this program comes with NO WARRANTY WHATSOEVER
% 
function xOut=vertcat(varargin)
  nv = length(varargin);
  for i=1:nv
    if(isa(varargin{i},'deriv1s'))
      np = nindep(varargin{i});
      break;
    end
  end
  offs_r = 0;
  ii = [];jj = [];vv = [];
  for i=1:nv
    if(isa(varargin{i},'deriv1s'))
      vs{i} = varargin{i}.v;
      [ii2,jj2,vv2] = find(varargin{i}.d);
      ii2 = ii2+offs_r;
      ii=[ii;ii2];
      jj=[jj;jj2];
      vv=[vv;vv2];
    else
      vs{i} = varargin{i};
    end
    offs_r = offs_r + size(vs{i},1);
  end
  xOut.v = vertcat(vs{:});
  xOut.d = sparse(ii,jj,vv);
  xOut=class(xOut,'deriv1s');


